#include <iostream>
#include <sys/types.h>
#include<unistd.h>
#include <fcntl.h>
#include<string>
#include <sys/stat.h>
#include"named_pipe.h"

using namespace std;

class name_pipe
{
    public:
    name_pipe()
    {
        mkfifo(_path.c_str(),_mode);
    }
    ~name_pipe()
    {
        unlink(_path.c_str());
    }
    string get_path()
    {
        return _path;
    }
    private:
    string _path=pipe_path;
    mode_t _mode=pipe_mode;
};



int main()
{
    name_pipe _pipe;
    int fd=open(_pipe.get_path().c_str(),O_WRONLY);

    while(true)
    {
        char buf[]="i am process A";
        write(fd,buf,sizeof(buf));
        sleep(2);
    }
    return 0;
}
